package com.story.aistory.controller;


import com.story.aistory.domain.dto.StoryDto;
import com.story.aistory.domain.po.Result;
import com.story.aistory.domain.po.Story;
import com.story.aistory.service.IStoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hui
 * @since 2025-03-12
 */
@Tag(name = "故事相关接口", description = "故事相关接口")
@RequiredArgsConstructor
@RestController
@RequestMapping("/story")
public class StoryController {

    private final IStoryService storyService;

    //头像上传
    @PostMapping("/saveStory")
    @Operation(summary = "保存故事")
    public  Result saveStory(@RequestBody StoryDto storyDto){
        return storyService.saveStory(storyDto);
    }
    @PostMapping("/getStoryById")
    @Operation(summary = "根据故事ID获取故事")
    public Result getStoryById(@RequestParam("storyId") Integer storyId){
        return storyService.getStoryById(storyId);
    }
    @GetMapping("/getStories")
    @Operation(summary = "获取所有故事")
    public Result<List<StoryDto>> getStories(){
        return storyService.getStories();
    }

    @DeleteMapping("/deleteStory")
    @Operation(summary = "删除故事")
    public Result deleteStory(@RequestParam("storyId") Integer storyId){
        return storyService.deleteStory(storyId);
    }
    //修改故事展示
    @PutMapping("/updateStory")
    @Operation(summary = "修改故事")
    public Result updateStory(@RequestBody StoryDto storyDto){
        return storyService.updateStory(storyDto);
    }

    @GetMapping("like")
    @Operation(summary = "点赞故事--type=1为点赞，type=0为取消点赞")
    public Result likeStory(@RequestParam("storyId") Integer storyId, @RequestParam("type") Integer type){
        return storyService.likeStory(storyId,type);
    }

    @GetMapping("/read")
    @Operation(summary = "阅读故事")
    public Result readStory(@RequestParam("storyId") Integer storyId){
        return storyService.readStory(storyId);
    }

}
